import request from '@/utils/request'

// 查询激活码列表
export function listActivationCode(query) {
  return request({
    url: '/machine/code/list',
    method: 'get',
    params: query
  })
}

// 查询激活码详细
export function getActivationCode(id) {
  return request({
    url: '/machine/code/' + id,
    method: 'get'
  })
}

// 新增激活码
export function addActivationCode(data) {
  return request({
    url: '/machine/code',
    method: 'post',
    data: data
  })
}

// 修改激活码
export function updateActivationCode(data) {
  return request({
    url: '/machine/code',
    method: 'put',
    data: data
  })
}

// 删除激活码
export function delActivationCode(id) {
  return request({
    url: '/machine/code/' + id,
    method: 'delete'
  })
}

// 根据项目ID查询激活码列表
export function getActivationCodeByProId(proId) {
  return request({
    url: '/machine/code/proId/' + proId,
    method: 'get'
  })
}

// 根据激活码查询
export function getActivationCodeByCode(activeCode) {
  return request({
    url: '/machine/code/code/' + activeCode,
    method: 'get'
  })
}

// 批量生成激活码
export function batchGenerateActivationCode(data) {
  return request({
    url: '/machine/code/generate',
    method: 'post',
    data: data
  })
}

// 根据用户ID查询激活码列表
export function getActivationCodesByUserId(allocateUserId) {
  return request({
    url: '/machine/code/userId/' + allocateUserId,
    method: 'get'
  })
}

// 根据项目ID查询未分配的激活码
export function getUnallocatedActivationCodesByProId(proId) {
  return request({
    url: '/machine/code/unallocated/' + proId,
    method: 'get'
  })
}

// 分配激活码给用户
export function allocateActivationCodes(data) {
  return request({
    url: '/machine/code/allocate',
    method: 'post',
    data: data
  })
}

// 批量分配激活码给用户
export function batchAllocateActivationCodes(data) {
  return request({
    url: '/machine/code/batchAllocate',
    method: 'post',
    data: data
  })
}